﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeltaPlcSystem
{
    public class DeviceClass
    {
        public string Ip=string.Empty;

        public string PlcMode= string.Empty;
        public string IsEnable = string.Empty;

        public string InterfaceID = string.Empty;
        public string EquipName = string.Empty;
        public string EquipType = string.Empty;
        public string Status = string.Empty;
        public string StatusCode = string.Empty;
        public string PassQty = string.Empty;
        public string FailQty = string.Empty;
        public string ErrorCnt = string.Empty;
        public string ErrorTimes = string.Empty;
        public string CycleTime = string.Empty;
        public string RunningTime = string.Empty;
        public string WaitingTime = string.Empty;
        public string SelfCheck = string.Empty;
        public string InputQty = string.Empty;
        public string Barcode = string.Empty;
        public string Model = string.Empty;
        public string CT_Q = string.Empty;
        public string CT_M = string.Empty;
        public double ModulusValue = 1d;       
        public bool IsThreadRun = false;
        public ModbusTcp PlcModbus=null;
        public bool IsReadData = false;
        public bool IsThreadControl = true;//删除设备
        public bool IsConnected = false;
        public bool IsError = false;
        public StringBuilder LogStr=new StringBuilder();
        public string LogPath = string.Empty;

        public string VirtualMachine=string.Empty;

        //2025/2/19 xiaoqiang 定时启停开关
        public bool IsTimeEnable = false;


        public System.Timers.Timer TbsTimer = new System.Timers.Timer();
        public int TbsState = 0; //0 2实际; 1异常
        public int TbsCount = 0;

        public DeviceClass()
        {
            TbsTimer.Interval = 1000;

            TbsTimer.Elapsed += TbsTimer_Elapsed;

            TbsTimer.Start();
        }

        private void TbsTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (TbsState == 1)
            {
                if (TbsCount >= Form1.TbsTime)
                {
                    TbsState = 2;
                    TbsCount = 0;
                }
                else
                {
                    TbsCount++;
                }
            }
        }
    }
}
